from django.db import models
from django.conf import settings
get_upload_to = settings.GET_IMAGE
# Create your models here.
class Users(models.Model):
  username = models.CharField(max_length=50, blank=False, null=False)
  first_name = models.CharField(max_length=50, blank=False, null=False)
  last_name= models.CharField(max_length=50, blank=True, null=False)
  email_id= models.CharField(max_length=100, default=True, blank=False, null=False)
  #order = models.PositiveIntegerField('Display Order', blank=True, null=True);

class PostAdd(models.Model):
  ad_type_choice = (('buy', 'buy'), ('sell', 'sell'))
  ad_type = models.CharField(max_length=50, choices=ad_type_choice, blank=False, null=False)
  ad_title = models.CharField(max_length=50, blank=False, null=False)
  ad_description  = models.TextField(blank=False, null=False)
  ad_posted_by = models.CharField(max_length=100, default='', blank=False, null=False)
  ad_quoted_price = models.FloatField(max_length=100, default=0.0, blank=False, null=False)
  ad_mobileno = models.CharField(max_length=20, default='', blank=False, null=False)
  ad_email = models.CharField(max_length=50, blank=True, null=False)
  ad_condition =models.CharField(max_length=50, blank=True, null=False)
  ad_location = models.CharField(max_length=50, blank=True, null=False)
  ad_latest_date = models.DateField(auto_now=True)
  ad_first_date = models.DateField(auto_now_add=True)
  #ad_image = models.ImageField(upload_to=get_upload_to, blank=True, null=True)
  ad_image =  models.FileField(upload_to='image/documents/%Y/%m/%d')
  ad_status = models.CharField(max_length=10, default='A', blank=False, null=False)
  ad_pincode = models.IntegerField(max_length=12, blank=False, null=False)

class PostComment(models.Model):
  post_id = models.ForeignKey(PostAdd)
  comment_description = models.TextField(blank=False, null=False)
  comment_by = models.CharField(max_length=100, default='', blank=False, null=False)
  comment_location = models.CharField(max_length=100, default='', blank=False, null=False)
  comment_on = models.DateField(auto_now=True)
  comment_first_on = models.DateField(auto_now_add=True)
  comment_email = models.CharField(max_length=50, blank=True, null=False)
  comment_status = models.CharField(max_length=10, default='A', blank=False, null=False)

class gLocation(models.Model):
  #location_id = models.AutoField(primary_key=True)
  loc_name = models.CharField(max_length=100)


class gadd_users(models.Model):
  #user_id = models.AutoField(primary_key=True)
  first_name = models.CharField(max_length=30)
  last_name = models.CharField(max_length=30)
  gender = models.CharField(max_length=30)
  location = models.ForeignKey(gLocation)

